package controller

import (
	"sale-admin/config/mysql"
	"sale-admin/internal/app/web/service/shop"

	"192.168.1.75/go-pkg/response"
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
)

type Shop struct{}

// ShopInfoDetail 获取商户信息
func (s Shop) ShopInfoDetail(c *gin.Context) {
	var params struct {
		ShopID string `json:"shop_id"`
	}
	c.ShouldBindBodyWith(&params, binding.JSON)
	// 一般情况获取当前登录商户的信息
	// 在配置支付方式时，获取指定商户的商户信息
	merchantID := c.GetString("merchant_id")
	if params.ShopID != "" {
		merchantID = params.ShopID
	}
	db := mysql.NewDB()
	data, err := shop.ShopService{}.ShopInfoDetail(c.Request.Context(), db, merchantID)
	response.JSON(c, data, err)
}
